package edu.lnu.ums.entities.security;

import java.security.Principal;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Table;

import edu.lnu.ums.entities.core.AbstractEntity;

@Entity
@Table(name = "account")
public class User extends AbstractEntity implements Principal {

	private static final long serialVersionUID = -885308099424380075L;

	@Column(name = "login")
	private String name;

	@Column(name = "userType")
	private String type;

	@Column(name = "pass")
	private String password;

	@Column(name = "activeUser")
	private Boolean active;

	public String getType() {
		return type;
	}

	public void setType(String type) {
		this.type = type;
	}
	
	public String getName() {
		return name;
	}

	public void setName(String name) {
		this.name = name;
	}

	public String getPassword() {
		return password;
	}

	public void setPassword(String password) {
		this.password = password;
	}

	public Boolean getActive() {
		return active;
	}

	public void setActive(Boolean active) {
		this.active = active;
	}

	public int hashCode() {
		return name.hashCode();
	}

	public boolean equals(Object o) {
		if (!(o instanceof User)) {
			return false;
		}
		return name.equals(((User) o).name);
	}

	public String toString() {
		return name;
	}

}
